<!-- 仅在有用户名密码输入的情况下会自动带入，一般只有密码的时候不需要 --> 
<template>
  <div>
    <el-input
      type="password"
      v-model="pswd"
      :readonly="readonly"
      placeholder="密码"
      show-password
      @focus="enablePassword"
      @input.enter.native="changePassword"
    >
     <i slot="prefix" class="el-icon-lock"></i>
    </el-input>
  </div>
</template>
<script>
export default {
  name: 'PasswordInput',
  props: {
    password: String
  },
  components: {},
  computed: {},
  data() {
    return {
      pswd: '',
      readonly: true
    }
  },
  mounted() {
    this.pswd = this.password
  },
  methods: {
    /**
     * 允许密码输入
     */
    enablePassword() {
      this.readonly = false
    },

    /**
     * 调父组件 方法
     */
    changePassword() {
      this.$emit('changePassword',this.pswd)
    }
  }
}
</script>

<style lang="scss">
</style>
